package com.ktgj.hotel.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.ktgj.common.log.annotation.Log;
import com.ktgj.common.log.enums.BusinessType;
import com.ktgj.common.security.annotation.PreAuthorize;
import com.ktgj.hotel.domain.HotelCommentType;
import com.ktgj.hotel.service.IHotelCommentTypeService;
import com.ktgj.common.core.web.controller.BaseController;
import com.ktgj.common.core.web.domain.AjaxResult;
import com.ktgj.common.core.utils.poi.ExcelUtil;
import com.ktgj.common.core.web.page.TableDataInfo;

/**
 * 点评类型Controller
 * 
 * @author ruoyi
 * @date 2021-12-08
 */
@ControllerAdvice
@RestController
@RequestMapping("/type")
public class HotelCommentTypeController extends BaseController
{
    @Autowired
    private IHotelCommentTypeService hotelCommentTypeService;

    /**
     * 查询点评类型列表
     */
    @PreAuthorize(hasPermi = "hotel:type:list")
    @GetMapping("/list")
    public TableDataInfo list(HotelCommentType hotelCommentType)
    {
        startPage();
        List<HotelCommentType> list = hotelCommentTypeService.selectHotelCommentTypeList(hotelCommentType);
        return getDataTable(list);
    }

    /**
     * 导出点评类型列表
     */
    @PreAuthorize(hasPermi = "hotel:type:export")
    @Log(title = "点评类型", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, HotelCommentType hotelCommentType) throws IOException
    {
        List<HotelCommentType> list = hotelCommentTypeService.selectHotelCommentTypeList(hotelCommentType);
        ExcelUtil<HotelCommentType> util = new ExcelUtil<HotelCommentType>(HotelCommentType.class);
        util.exportExcel(response, list, "点评类型数据");
    }

    /**
     * 获取点评类型详细信息
     */
    @PreAuthorize(hasPermi = "hotel:type:query")
    @GetMapping(value = "/{commenttypeid}")
    public AjaxResult getInfo(@PathVariable("commenttypeid") Long commenttypeid)
    {
        return AjaxResult.success(hotelCommentTypeService.selectHotelCommentTypeById(commenttypeid));
    }

    /**
     * 新增点评类型
     */
    @PreAuthorize(hasPermi = "hotel:type:add")
    @Log(title = "点评类型", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody HotelCommentType hotelCommentType)
    {
        return toAjax(hotelCommentTypeService.insertHotelCommentType(hotelCommentType));
    }

    /**
     * 修改点评类型
     */
    @PreAuthorize(hasPermi = "hotel:type:edit")
    @Log(title = "点评类型", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody HotelCommentType hotelCommentType)
    {
        return toAjax(hotelCommentTypeService.updateHotelCommentType(hotelCommentType));
    }

    /**
     * 删除点评类型
     */
    @PreAuthorize(hasPermi = "hotel:type:remove")
    @Log(title = "点评类型", businessType = BusinessType.DELETE)
	@DeleteMapping("/{commenttypeids}")
    public AjaxResult remove(@PathVariable Long[] commenttypeids)
    {
        return toAjax(hotelCommentTypeService.deleteHotelCommentTypeByIds(commenttypeids));
    }
}
